package com.atguigu.command.tv;

import com.atguigu.command.Command;
import com.atguigu.command.LightReceiver;

/**
 * @program: design-patterns
 * @author: yangshen
 * @description:  电视机打开的命令
 * @create: 2022-03-01 14:00
 **/
public class TvOnCommand implements Command {

    /**
     * 聚合(电灯接收者)
     */
    private final TvReceiver tvReceiver;

    public TvOnCommand(TvReceiver tvReceiver) {
        this.tvReceiver = tvReceiver;
    }

    @Override
    public void execute() {
        //调用接收者的方法(可以是接收者的任一方法：打开或关闭)
        tvReceiver.on();
    }

    @Override
    public void undo() {
        //调用接收者的方法(可以是接收者的任一方法：打开或关闭)
        tvReceiver.off();
    }
}
